<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/pub/head_latest.inc"%>
<title>Link list</title>
<style>
html,body {
    padding: 0px;
    background: #fff;
}
</style>
</head>
<body>
	<!-- Search Form -->
	<div class="mainsearch">
		<div class="searchbox">
			<form id="formsearch" class="l-form" method="get">
				<table>
					<tr>
						<td align="right" class="l-table-edit-td">字段名称：</td>
						<td align="left" class="l-table-edit-td" style="width: 160px">
							<input name="fieldName" type="text" ltype="text" class="field" />
						</td>
						<td align="left" class="l-table-edit-td"></td>
						<td align="left" class="l-table-edit-td"></td>
						<td align="left" class="l-table-edit-td">
							<button type="button" id="btnSearch" class="l-button l-button-submit"><i class="fa fa-search"></i> 搜索</button>
						</td>
						<td align="left" class="l-table-edit-td">
							<button type="reset" id="btnReset" class="l-button l-button-test" ><i class="fa fa-exchange"></i> 重置</button>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<!-- Grid List-->
	<div id="maingrid"></div>

	<script type="text/javascript">
   	  function badousoft(){}
		badousoft.ajax=function(s){
		    jQuery.ajax(s);
		}	
   	  var baseUrl = '${baseURL}/report/link/link';
      //List 
      var grid = $("#maingrid").ligerGrid({ 
          columns: [
				 {display:"钻取字段",name:"linkName",width:150,type:"text",align:"left",isSort : false},
				 {display:"窗口名称",name:"name",width:150,type:"text",align:"left",isSort : false},
				 {display:"参数",name:"params",width:150,type:"text",align:"left",isSort : false},
				 {display:"标题",name:"title",width:150,type:"text",align:"left",isSort : false},
				 {display:"打开方式",name:"openTypeDesc",width:150,type:"text",align:"left",isSort : false },
           		 {display:"样式",name:"css",width:150,type:"text",align:"left",isSort : false}
				 ],
          dataAction: 'server',toolbar: {},
          url:  baseUrl+'list/listJSON.do?csId=${csId}', sortName: 'code',
          width: '100%', height: '100%',heightDiff:-10, checkbox: true,
          pageParmName:"pageNo",pageSizeOptions:[${pageOptions}],pagesizeParmName:"perPageSize",
          rowHeight:23,rownumbers:true,isScroll:true,sortnameParmName:"sortName",
          sortorderParmName:"sortOrder",checkbox:true,pageSize: ${pageSize}
      });

      //DoubleClick
      LG.setGridDoubleClick(grid, FF_ModifyClickEvent);
      
      
      //Load toolbar
      LG.createToolbarButton(grid, [{id : "add", name : "新增", clickEvent : FF_AddClickEvent, icon : "a fa fa-plus-square-o" ,type:"icon"},
     								{id : "modify", name : "修改", clickEvent : FF_ModifyClickEvent, icon : "a fa fa-pencil-square-o" ,type:"icon"},
     								{id : "delete", name : "删除", clickEvent : FF_DeletedClickEvent, icon : "a fa fa-minus-square-o" ,type:"icon"}]);

	  //搜索事件
      $("#btnSearch").click(function(e){
    	  var json = LG.bulidFilterParams($("#formsearch"));
          grid.set('parms', json);
            //采用原来的请求地址，带上参数加载数据
		  grid.loadData();
      });
  	  
  	   //重置事件
      $("#btnReset").click(function(e){
           grid.set('parms', null);
            //采用原来的请求地址，带上参数加载数据
		   grid.loadData();
      });
	  
	   $("#formsearch").ligerForm();
	  
      //Toolbar
      //Add Event
      function FF_AddClickEvent(btnItem){
    		FF_ShowDialog(null,true);
      }
       //Modify Event
      function FF_ModifyClickEvent(btnItem){
    	  var row = grid.getLastSelected();
        	if (!row) { alert("请先选择需要修改的行!"); return false;}
        	FF_ShowDialog({
        		pkId : row.id,fieldName : row.fieldName,css : row.css,
        		name : row.name,linkName : row.linkName,title : row.title,
        		openType : row.openType, linkURL : row.linkURL,params : row.params,	linkCode : row.linkCode
        	}, false);
       }
      //Delete Evvent
      function FF_DeletedClickEvent(btnItem){
      	var selectedRow = grid.getCheckedRows();
      	if (!selectedRow || !selectedRow.length) { alert("请选择需要操作的行记录!"); return false;}
      	jQuery.ligerDialog.confirm('确认删除?', function (confirm) {
              if (confirm){
              	 badousoft.ajax({
   					type: "GET",
   					url: baseUrl+"delete/delete.do",
   					dataType : "json",
   					data: "ids="+LG.serialIdParam(selectedRow),
   					beforeSend: function (){
		                LG.loading = true;
		                LG.showLoading('操作中...');
		            },
		            complete: function (){
		                LG.loading = false;	  
		                LG.hideLoading();
		            },
   					success: function(msg){
     					if(msg && msg.hasOk){
     						 grid.loadData();
     						 alert('操作成功!');
     					}else{
   						 alert("操作失败，原因如下:\n"+msg.message+"\n请联系系统管理员!");
     					}
   					}
 				 });
              }
        });
      }
  </script>

	<%@ include file="linklist_detail.jsp"%>

</body>
</html>